<template>
  <div class="dashboard-container">
    <div class="breadcrumb-container flex-row">
      <breadcrumb />
      <div class="rightTwo">
        <a style="margin-left: 10px;" @click="exportExcelFile"><i class="el-icon-excel" /> 导出</a>
        <a style="margin-left: 10px;" @click="toMap"><i class="el-icon-location-information" /> 地图看房</a>
      </div>
    </div>
    <el-divider />
    <div class="overview-tabs">
      <scr-list @tableData="tableData"  ref="getDataObj"/>
      <list-table :my-data="dataA" :my-listQuery='listQuery' @getPageData="getPageData" />
    </div>
  </div>

</template>

<script>
import Breadcrumb from '@/components/Breadcrumb'
import scrList from './components/scr.vue'
import listTable from './components/table.vue'
import { exportExcel } from '@/api/house'
import { getToken } from '@/utils/auth'
import { getById, add, update, page, pageByAddress } from '@/api/house'
export default {
  name: 'PagePermission',
  components: { Breadcrumb, scrList, listTable },
  data() {
    return {
      dataA: {},
      listQuery:{}
    }
  },
  mounted() {

  },
  methods: {
    handleRolesChange() {
      this.$router.push({ path: '/permission/index?' + +new Date() })
    },
    tableData(val) {
      this.dataA = val
    },
    toMap() {
      this.$router.push({ path: '/house/map' })
    },
    getPageData(Query) {
      let obj =this.$refs.getDataObj.listQuery
      obj.limit = Query.limit
      obj.page = Query.page
      obj = Object.assign(obj,Query);
      page(obj).then(response => {
        this.tableData(response)
      })
    },
    exportExcelFile() {
        let obj = this.$refs.getDataObj.getTest1()
        delete obj.limit
        delete obj.page
        if (!obj.tag)obj.tag = ''
        if (!obj.roomNumber)obj.roomNumber = ''
        for(let i in obj){
          if(obj[i] == null ||  obj[i] == undefined){
              obj[i] = ''
          }
        }
      const href = process.env.VUE_APP_BASE_API + 'house/exportExcel?X-Token=' + getToken() + '&address='+obj.address  + '&bd='+obj.bd + '&operator='+obj.operator + '&owner='+obj.owner + '&status='+obj.status + '&tag='+obj.tag + '&roomNumber='+obj.roomNumber + '&type='+obj.type
      window.open(href, '_blank')
    }

  }
}
</script>

<style lang="scss" scoped>
.breadcrumb-container {
  position: relative;
  width: 100%;
  height: 60px;
  padding: 0 14px;

  &::after {
    content: '';
    position: absolute;
    left: 0px;
    top: 50%;
    width: 2px;
    height: 37px;
    background-color: #5AC6B7;
    transform: translateY(-50%);
  }
}
.overview-tabs{padding: 10px;}
.rightTwo{position: absolute;top: 10px;right: 10px;width: 120px;font-size: 13px;color: #5AC6B7;}
.rightTwo p{display: inline-block;margin-left: 8px;}
</style>
